function GetType(obj?: any) {
  return Object.prototype.toString.call(obj).replace(/^\[object (\S*)\]$/, "$1");
}

console.log(GetType("")); // [object String]
console.log(GetType(2)); // [object Number]
console.log(GetType(NaN)); // [object Number]
console.log(GetType(undefined)); // [object Undefined]
console.log(GetType({})); // [object Object]
console.log(GetType([])); // [object Array]
console.log(GetType(null)); // [object Null]
console.log(GetType(/a/g)); // [object RegExp]
console.log(GetType(new Date())); // [object Date]
console.log(GetType(true)); // [object Boolean]
console.log(GetType(function SayHello() { })); // [object Function]
console.log(GetType(class Person { })); // [object Function]
console.log(GetType(Symbol("bar"))); // [object Symbol]
console.log(GetType()); // Undefined
